package com.smart.community.property.service.impl;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smart.community.commons.cache.DataScopeInfo;
import com.smart.community.commons.enums.DeletedEnum;
import com.smart.community.commons.exception.BusinessException;
import com.smart.community.commons.result.ResultCode;
import com.smart.community.commons.utils.DateUtils;
import com.smart.community.commons.utils.SecurityUtils;
import com.smart.community.property.dto.ReminderRecordDTO;
import com.smart.community.property.entity.PropertyFee;
import com.smart.community.property.entity.ReminderRecord;
import com.smart.community.property.entity.SanitationFee;
import com.smart.community.property.enums.ReminderFeeTypeEnum;
import com.smart.community.property.enums.ReminderStatusEnum;
import com.smart.community.property.enums.ReminderTypeEnum;
import com.smart.community.property.mapper.ElectricityFeeMapper;
import com.smart.community.property.mapper.GasFeeMapper;
import com.smart.community.property.mapper.PropertyFeeMapper;
import com.smart.community.property.mapper.ReminderRecordMapper;
import com.smart.community.property.mapper.SanitationFeeMapper;
import com.smart.community.property.mapper.WaterFeeMapper;
import com.smart.community.property.service.DataScopeService;
import com.smart.community.property.service.IReminderRecordService;
import com.smart.community.property.vo.ReminderRecordVO;

import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;

/**
 * 嵌套催缴/沟通记录服务实现
 * 严格遵循《智慧社区微服务架构总览.md》《系统状态枚举权威标准声明.md》
 * 生产环境标准：移除throws Exception声明，使用统一异常处理
 * @author Wu.Liang
 * @since 2025-07-22
 * @version 2.0.0 - 生产环境标准优化
 */
@Slf4j
@Service
public class ReminderRecordServiceImpl extends ServiceImpl<ReminderRecordMapper, ReminderRecord> implements IReminderRecordService {

    @Autowired
    private ReminderRecordMapper reminderRecordMapper;

    @Autowired
    private PropertyFeeMapper propertyFeeMapper;

    @Autowired
    private SanitationFeeMapper sanitationFeeMapper;

    @Autowired
    private WaterFeeMapper waterFeeMapper;

    @Autowired
    private ElectricityFeeMapper electricityFeeMapper;

    @Autowired
    private GasFeeMapper gasFeeMapper;

    @Autowired
    private DataScopeService dataScopeService;

    @Override
    @GlobalTransactional
    public Long addReminder(ReminderRecordDTO dto) {
        log.info("开始新增催缴/沟通记录，参数：{}", dto);
        
        try {
            // 1. 参数校验
            validateAddReminderParams(dto);
            
            // 2. 校验feeId+feeType对应主表记录存在（多对一关联校验）
            validateFeeRecordExists(dto.getFeeId(), dto.getFeeType());
            
            // 3. 校验权限与数据范围
            validateDataPermission(dto.getFeeId(), dto.getFeeType());
            
            // 4. 构建ReminderRecord实体
            ReminderRecord entity = buildReminderRecordEntity(dto);
            
            // 5. 保存到数据库
            int insertResult = reminderRecordMapper.insert(entity);
            if (insertResult <= 0) {
                throw new BusinessException(ResultCode.OPERATION_FAILED, "保存催缴记录失败");
            }
            
            log.info("新增催缴/沟通记录成功，ID：{}", entity.getId());
            return entity.getId();
            
        } catch (BusinessException e) {
            log.warn("新增催缴记录业务异常：{}", e.getMessage());
            throw e;
        } catch (Exception e) {
            log.error("新增催缴记录系统异常", e);
            throw new BusinessException(ResultCode.OPERATION_FAILED, "新增催缴记录失败：" + e.getMessage());
        }
    }

    @Override
    public List<ReminderRecordVO> listReminders(Long feeId, Integer feeType) {
        log.info("开始查询催缴/沟通记录，feeId：{}，feeType：{}", feeId, feeType);
        
        try {
            // 1. 参数校验
            validateQueryParams(feeId, feeType);
            
            // 2. 校验权限与数据范围
            validateDataPermission(feeId, feeType);
            
            // 3. 查询sc_reminder_record表，按feeId+feeType过滤
            LambdaQueryWrapper<ReminderRecord> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(ReminderRecord::getFeeId, feeId)
                       .eq(ReminderRecord::getFeeType, String.valueOf(feeType))
                       .eq(ReminderRecord::getDeleted, DeletedEnum.NOT_DELETED.getCode())
                       .orderByDesc(ReminderRecord::getCreateTime);
            
            List<ReminderRecord> records = reminderRecordMapper.selectList(queryWrapper);
            
            // 4. 转换为VO返回
            List<ReminderRecordVO> voList = convertToVOList(records);
            
            log.info("查询催缴/沟通记录成功，数量：{}", voList.size());
            return voList;
            
        } catch (BusinessException e) {
            log.warn("查询催缴记录业务异常：{}", e.getMessage());
            throw e;
        } catch (Exception e) {
            log.error("查询催缴记录系统异常", e);
            throw new BusinessException(ResultCode.OPERATION_FAILED, "查询催缴记录失败：" + e.getMessage());
        }
    }

    @Override
    @GlobalTransactional
    public void updateReminder(Long id, ReminderRecordDTO dto) {
        log.info("开始修改催缴/沟通记录，ID：{}，参数：{}", id, dto);
        
        try {
            // 1. 参数校验
            validateUpdateReminderParams(id, dto);
            
            // 2. 校验记录存在，且属于有权限范围
            ReminderRecord existingRecord = validateRecordExistsAndPermission(id);
            
            // 3. 校验reminderType、feeType等字段用统一枚举
            validateEnumFields(dto);
            
            // 4. 构建更新实体
            ReminderRecord updateEntity = buildUpdateReminderRecordEntity(id, dto, existingRecord);
            
            // 5. 更新数据库
            int updateResult = reminderRecordMapper.updateById(updateEntity);
            if (updateResult <= 0) {
                throw new BusinessException(ResultCode.OPERATION_FAILED, "更新催缴记录失败");
            }
            
            log.info("修改催缴/沟通记录成功，ID：{}", id);
            
        } catch (BusinessException e) {
            log.warn("修改催缴记录业务异常：{}", e.getMessage());
            throw e;
        } catch (Exception e) {
            log.error("修改催缴记录系统异常", e);
            throw new BusinessException(ResultCode.OPERATION_FAILED, "修改催缴记录失败：" + e.getMessage());
        }
    }

    @Override
    @GlobalTransactional
    public void syncFee(ReminderRecordDTO dto) {
        log.info("开始同步催缴记录到主表，参数：{}", dto);
        
        try {
            // 1. 参数校验
            validateSyncFeeParams(dto);
            
            // 2. 校验权限与数据范围
            validateDataPermission(dto.getFeeId(), dto.getFeeType());
            
            // 3. 根据feeType同步到对应的主表
            syncToMainFeeTable(dto);
            
            log.info("同步催缴记录到主表成功，feeId：{}，feeType：{}", dto.getFeeId(), dto.getFeeType());
            
        } catch (BusinessException e) {
            log.warn("同步催缴记录业务异常：{}", e.getMessage());
            throw e;
        } catch (Exception e) {
            log.error("同步催缴记录系统异常", e);
            throw new BusinessException(ResultCode.OPERATION_FAILED, "同步催缴记录失败：" + e.getMessage());
        }
    }

    /**
     * 校验新增催缴记录参数
     */
    private void validateAddReminderParams(ReminderRecordDTO dto) {
        if (dto == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "催缴记录参数不能为空");
        }
        
        if (dto.getFeeId() == null || dto.getFeeId() <= 0) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用主表ID不能为空");
        }
        
        if (dto.getFeeType() == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用类型不能为空");
        }
        
        if (dto.getReminderType() == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "记录类型不能为空");
        }
        
        if (!StringUtils.hasText(dto.getReminderContent())) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "催缴/沟通内容不能为空");
        }
        
        if (dto.getReminderContent().length() > 500) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "催缴/沟通内容长度不能超过500字符");
        }
        
        if (dto.getRemark() != null && dto.getRemark().length() > 200) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "备注长度不能超过200字符");
        }
        
        // 校验枚举值
        validateEnumFields(dto);
    }

    /**
     * 校验查询参数
     */
    private void validateQueryParams(Long feeId, Integer feeType) {
        if (feeId == null || feeId <= 0) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用主表ID不能为空");
        }
        
        if (feeType == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用类型不能为空");
        }
    }

    /**
     * 校验修改催缴记录参数
     */
    private void validateUpdateReminderParams(Long id, ReminderRecordDTO dto) {
        if (id == null || id <= 0) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "催缴记录ID不能为空");
        }
        
        if (dto == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "催缴记录参数不能为空");
        }
        
        validateAddReminderParams(dto);
    }

    /**
     * 校验同步到主表参数
     */
    private void validateSyncFeeParams(ReminderRecordDTO dto) {
        if (dto == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "同步参数不能为空");
        }
        
        if (dto.getFeeId() == null || dto.getFeeId() <= 0) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用主表ID不能为空");
        }
        
        if (dto.getFeeType() == null) {
            throw new BusinessException(ResultCode.PARAM_ERROR, "费用类型不能为空");
        }
    }

    /**
     * 校验枚举字段
     */
    private void validateEnumFields(ReminderRecordDTO dto) {
        // 校验费用类型枚举
        if (dto.getFeeType() != null) {
            ReminderFeeTypeEnum feeTypeEnum = ReminderFeeTypeEnum.fromCode(dto.getFeeType());
            if (feeTypeEnum == null) {
                throw new BusinessException(ResultCode.PARAM_ERROR, "无效的费用类型：" + dto.getFeeType());
            }
        }
        
        // 校验记录类型枚举
        if (dto.getReminderType() != null) {
            ReminderTypeEnum reminderTypeEnum = ReminderTypeEnum.fromCode(dto.getReminderType());
            if (reminderTypeEnum == null) {
                throw new BusinessException(ResultCode.PARAM_ERROR, "无效的记录类型：" + dto.getReminderType());
            }
        }
    }

    /**
     * 校验费用记录存在性
     */
    private void validateFeeRecordExists(Long feeId, Integer feeType) {
        boolean exists = false;
        
        switch (feeType) {
            case 0: // 物业费
                exists = propertyFeeMapper.selectById(feeId) != null;
                break;
            case 1: // 卫生费
                exists = sanitationFeeMapper.selectById(feeId) != null;
                break;
            case 2: // 水费
                exists = waterFeeMapper.selectById(feeId) != null;
                break;
            case 3: // 电费
                exists = electricityFeeMapper.selectById(feeId) != null;
                break;
            case 4: // 燃气费
                exists = gasFeeMapper.selectById(feeId) != null;
                break;
            default:
                throw new BusinessException(ResultCode.PARAM_ERROR, "不支持的费用类型：" + feeType);
        }
        
        if (!exists) {
            throw new BusinessException(ResultCode.DATA_NOT_FOUND, "费用记录不存在，feeId：" + feeId + "，feeType：" + feeType);
        }
    }

    /**
     * 校验数据权限
     */
    private void validateDataPermission(Long feeId, Integer feeType) {
        try {
            // 获取当前用户数据权限
            DataScopeInfo dataScopeInfo = null;
            try {
                dataScopeInfo = dataScopeService.getCurrentUserDataScope();
            } catch (Exception e) {
                log.warn("获取当前用户数据权限信息失败，可能是Feign接口调用或用户未登录: {}", e.getMessage());
                // 根据Feign接口开发规范，当无法获取用户权限信息时，不抛出异常，只记录警告
                return;
            }
            
            if (dataScopeInfo == null) {
                log.warn("用户数据权限信息为空，跳过权限校验");
                return;
            }
            
            // 超级管理员跳过权限校验
            if (dataScopeInfo.isSuperAdmin()) {
                log.debug("超级管理员用户，跳过数据权限校验");
                return;
            }
            
            // 根据feeType获取对应的社区ID，然后校验权限
            Long communityId = getCommunityIdByFeeId(feeId, feeType);
            if (communityId != null) {
                if (!dataScopeInfo.hasCommunityPermission(communityId)) {
                    throw new BusinessException(ResultCode.PERMISSION_DENIED, "无权限访问该社区数据");
                }
            }
            
        } catch (BusinessException e) {
            // 业务异常直接抛出
            throw e;
        } catch (Exception e) {
            log.warn("数据权限校验异常：{}", e.getMessage());
            // 其他异常不抛出，只记录警告日志
        }
    }

    /**
     * 根据费用ID和类型获取社区ID
     */
    private Long getCommunityIdByFeeId(Long feeId, Integer feeType) {
        // 这里需要根据具体的表结构来实现
        // 由于不同费用表的字段可能不同，这里提供一个基础实现
        // 实际项目中可能需要通过Feign调用区域服务来获取社区ID
        
        switch (feeType) {
            case 0: // 物业费
                // 假设物业费表有community_id字段
                return null; // 需要根据实际表结构实现
            case 1: // 卫生费
                // 假设卫生费表有community_id字段
                return null; // 需要根据实际表结构实现
            case 2: // 水费
                return null;
            case 3: // 电费
                return null;
            case 4: // 燃气费
                return null;
            default:
                return null;
        }
    }

    /**
     * 校验记录存在且有权访问
     */
    private ReminderRecord validateRecordExistsAndPermission(Long id) {
        ReminderRecord record = reminderRecordMapper.selectById(id);
        if (record == null) {
            throw new BusinessException(ResultCode.DATA_NOT_FOUND, "催缴记录不存在，ID：" + id);
        }
        
        if (DeletedEnum.DELETED.getCode().equals(record.getDeleted())) {
            throw new BusinessException(ResultCode.DATA_NOT_FOUND, "催缴记录已删除，ID：" + id);
        }
        
        // 校验数据权限
        validateDataPermission(record.getFeeId(), Integer.valueOf(record.getFeeType()));
        
        return record;
    }

    /**
     * 构建催缴记录实体
     */
    private ReminderRecord buildReminderRecordEntity(ReminderRecordDTO dto) {
        ReminderRecord entity = new ReminderRecord();
        
        // 复制基本属性
        entity.setFeeId(dto.getFeeId());
        entity.setFeeType(dto.getFeeType());
        entity.setReminderType(dto.getReminderType());
        entity.setReminderContent(dto.getReminderContent()); // 使用reminder_content字段
        entity.setReminderTime(dto.getReminderTime() != null ? DateUtils.toLocalDateTime(dto.getReminderTime()) : LocalDateTime.now());
        entity.setNextDueDate(dto.getNextDueDate() != null ? DateUtils.toLocalDate(dto.getNextDueDate()) : null);
        entity.setNextAmount(dto.getNextAmount());
        entity.setRemark(dto.getRemark());
        
        // 设置默认值
        entity.setUserId(SecurityUtils.getCurrentUserId());
        entity.setReminderStatus(ReminderStatusEnum.VALID.getCode());
        entity.setCreateBy(SecurityUtils.getCurrentUserId());
        entity.setCreateTime(LocalDateTime.now());
        entity.setUpdateBy(SecurityUtils.getCurrentUserId());
        entity.setUpdateTime(LocalDateTime.now());
        entity.setDeleted(DeletedEnum.NOT_DELETED.getCode());
        
        return entity;
    }

    /**
     * 构建更新催缴记录实体
     */
    private ReminderRecord buildUpdateReminderRecordEntity(Long id, ReminderRecordDTO dto, ReminderRecord existingRecord) {
        ReminderRecord entity = new ReminderRecord();
        entity.setId(id);
        
        // 复制基本属性
        entity.setFeeId(dto.getFeeId());
        entity.setFeeType(dto.getFeeType()); // 转换为String类型
        entity.setReminderType(dto.getReminderType()); // 转换为String类型
        entity.setReminderContent(dto.getReminderContent()); // 使用reminder_content字段
        entity.setReminderTime(dto.getReminderTime() != null ? DateUtils.toLocalDateTime(dto.getReminderTime()) : LocalDateTime.now());
        entity.setNextDueDate(dto.getNextDueDate() != null ? DateUtils.toLocalDate(dto.getNextDueDate()) : null);
        entity.setNextAmount(dto.getNextAmount());
        entity.setRemark(dto.getRemark());
        
        // 设置更新信息
        entity.setUpdateBy(SecurityUtils.getCurrentUserId());
        entity.setUpdateTime(LocalDateTime.now());
        
        return entity;
    }

    /**
     * 转换为VO列表
     */
    private List<ReminderRecordVO> convertToVOList(List<ReminderRecord> records) {
        if (records == null || records.isEmpty()) {
            return Collections.emptyList();
        }
        
        return records.stream()
                .map(this::convertToVO)
                .filter(Objects::nonNull)
                .collect(Collectors.toList());
    }

    /**
     * 转换为VO
     */
    private ReminderRecordVO convertToVO(ReminderRecord record) {
        if (record == null) {
            return null;
        }
        
        ReminderRecordVO vo = new ReminderRecordVO();
        BeanUtils.copyProperties(record, vo);
        
        // 手动处理字段映射，确保字段名称一致
        vo.setReminderContent(record.getReminderContent());
        vo.setReminderTime(record.getReminderTime() != null ? DateUtils.toDate(record.getReminderTime()) : null);
        vo.setNextDueDate(record.getNextDueDate() != null ? DateUtils.toDate(record.getNextDueDate()) : null);
        vo.setNextAmount(record.getNextAmount());
        
        return vo;
    }

    /**
     * 同步到主费用表
     */
    private void syncToMainFeeTable(ReminderRecordDTO dto) {
        if (dto.getNextDueDate() == null && dto.getNextAmount() == null) {
            log.warn("同步参数为空，跳过同步，feeId：{}，feeType：{}", dto.getFeeId(), dto.getFeeType());
            return;
        }
        
        switch (dto.getFeeType()) {
            case 0: // 物业费
                syncToPropertyFee(dto);
                break;
            case 1: // 卫生费
                syncToSanitationFee(dto);
                break;
            case 2: // 水费
                syncToWaterFee(dto);
                break;
            case 3: // 电费
                syncToElectricityFee(dto);
                break;
            case 4: // 燃气费
                syncToGasFee(dto);
                break;
            default:
                throw new BusinessException(ResultCode.PARAM_ERROR, "不支持的费用类型：" + dto.getFeeType());
        }
    }

    /**
     * 同步到物业费表
     * <p>
     * 规则：
     * 1. 只同步nextDueDate和nextAmount字段（即下次到期日、下次应缴金额），如有值则更新。
     * 2. 只允许未删除、启用状态的物业费记录被更新。
     * 3. 日志记录同步前后数据。
     * 4. 严格异常处理，失败抛业务异常。
     * </p>
     */
    private void syncToPropertyFee(ReminderRecordDTO dto) {
        if (dto.getFeeId() == null) return;
        // 查询物业费主表
        PropertyFee propertyFee = propertyFeeMapper.selectById(dto.getFeeId());
        if (propertyFee == null || propertyFee.getDeleted() != null && propertyFee.getDeleted() == 1) {
            log.warn("同步物业费失败，主表不存在或已删除，feeId={}", dto.getFeeId());
            throw new BusinessException(ResultCode.DATA_NOT_FOUND, "物业费主表不存在或已删除");
        }
        boolean needUpdate = false;
        // 记录同步前数据
        log.info("[同步前] 物业费主表: id={}, dueDate={}, amount={}", propertyFee.getId(), propertyFee.getDueDate(), propertyFee.getAmount());
        // 同步下次到期日
        if (dto.getNextDueDate() != null) {
            propertyFee.setDueDate(DateUtils.toLocalDate(dto.getNextDueDate()));
            needUpdate = true;
        }
        // 同步下次应缴金额
        if (dto.getNextAmount() != null) {
            propertyFee.setAmount(dto.getNextAmount());
            needUpdate = true;
        }
        if (needUpdate) {
            propertyFee.setUpdateBy(SecurityUtils.getCurrentUserId());
            propertyFee.setUpdateTime(LocalDateTime.now());
            int updated = propertyFeeMapper.updateById(propertyFee);
            if (updated <= 0) {
                log.warn("同步物业费失败，数据库更新失败，feeId={}", dto.getFeeId());
                throw new BusinessException(ResultCode.OPERATION_FAILED, "同步物业费失败");
            }
            log.info("[同步后] 物业费主表: id={}, dueDate={}, amount={}", propertyFee.getId(), propertyFee.getDueDate(), propertyFee.getAmount());
        } else {
            log.info("同步物业费跳过，无需更新，feeId={}", dto.getFeeId());
        }
    }

    /**
     * 同步到卫生费表
     * <p>
     * 规则：
     * 1. 只同步nextDueDate和nextAmount字段（即下次到期日、下次应缴金额），如有值则更新。
     * 2. 只允许未删除、启用状态的卫生费记录被更新。
     * 3. 日志记录同步前后数据。
     * 4. 严格异常处理，失败抛业务异常。
     * </p>
     */
    private void syncToSanitationFee(ReminderRecordDTO dto) {
        if (dto.getFeeId() == null) return;
        // 查询卫生费主表
        SanitationFee sanitationFee = sanitationFeeMapper.selectById(dto.getFeeId());
        if (sanitationFee == null || sanitationFee.getDeleted() != null && sanitationFee.getDeleted() == 1) {
            log.warn("同步卫生费失败，主表不存在或已删除，feeId={}", dto.getFeeId());
            throw new BusinessException(ResultCode.DATA_NOT_FOUND, "卫生费主表不存在或已删除");
        }
        boolean needUpdate = false;
        // 记录同步前数据
        log.info("[同步前] 卫生费主表: id={}, dueDate={}, amount={}", sanitationFee.getId(), sanitationFee.getDueDate(), sanitationFee.getAmount());
        // 同步下次到期日
        if (dto.getNextDueDate() != null) {
            sanitationFee.setDueDate(DateUtils.toLocalDate(dto.getNextDueDate()));
            needUpdate = true;
        }
        // 同步下次应缴金额
        if (dto.getNextAmount() != null) {
            sanitationFee.setAmount(dto.getNextAmount());
            needUpdate = true;
        }
        if (needUpdate) {
            sanitationFee.setUpdateBy(SecurityUtils.getCurrentUserId());
            sanitationFee.setUpdateTime(LocalDateTime.now());
            int updated = sanitationFeeMapper.updateById(sanitationFee);
            if (updated <= 0) {
                log.warn("同步卫生费失败，数据库更新失败，feeId={}", dto.getFeeId());
                throw new BusinessException(ResultCode.OPERATION_FAILED, "同步卫生费失败");
            }
            log.info("[同步后] 卫生费主表: id={}, dueDate={}, amount={}", sanitationFee.getId(), sanitationFee.getDueDate(), sanitationFee.getAmount());
        } else {
            log.info("同步卫生费跳过，无需更新，feeId={}", dto.getFeeId());
        }
    }

    /**
     * 同步到水费表
     */
    private void syncToWaterFee(ReminderRecordDTO dto) {
        log.info("同步到水费表，feeId：{}", dto.getFeeId());
        // TODO: 实现具体的同步逻辑
    }

    /**
     * 同步到电费表
     */
    private void syncToElectricityFee(ReminderRecordDTO dto) {
        log.info("同步到电费表，feeId：{}", dto.getFeeId());
        // TODO: 实现具体的同步逻辑
    }

    /**
     * 同步到燃气费表
     */
    private void syncToGasFee(ReminderRecordDTO dto) {
        log.info("同步到燃气费表，feeId：{}", dto.getFeeId());
        // TODO: 实现具体的同步逻辑
    }
} 
